package service

import (
	"github.com/crack007/go-im/src/common/dao"
	"github.com/crack007/go-im/src/common/model"
	"github.com/crack007/go-im/src/module/api/dto"
)

type contactService struct {
}

func (s *contactService) List(userModel *model.UserModel, queryDto *dto.QueryDto) *dto.ContactDto {
	contactDto := dto.NewContactDto()
	contactList := dao.ContactDao.List(userModel.Id, queryDto.Page, queryDto.Size)
	for _, contactEntity := range contactList {
		userEntity := dao.UserDao.GetByUserId(contactEntity.RelateUserID)
		userDto := dto.NewUserDto()
		userDto.Id = userEntity.UserID
		userDto.Nickname = userEntity.Nickname
		contactDto.List = append(contactDto.List, userDto)
	}
	return contactDto
}
